var app = getApp();
var util = require('../../utils/util.js');  
Page({
	data: {
    items: [
      {id: '0', value: '陌颜'},
      {id: '1', value: '哈哈', checked: 'true'}
    ],
    type: 1
  },
  radioChange(e) {
    console.log('radio发生change事件，携带value值为：', e);
    app.globalData.fpname = e.detail.value;
    app.globalData.type = this.data.type;
    // wx.switchTab({
    //   url:'../charterrelease/index'
    // })
    wx.navigateBack({
      delta: 1
    })

  },
  goinvoicerise: function(){
  	// wx.switchTab({
   //    url: '../invoicerise/index'
   //  })
   wx.navigateBack({
      delta: 1
    })
  },
  onShow: function () {
    var that = this;
    wx.getStorage({
      key: 'type',
      success(res) {
        that.setData({
          type: res.data
        })
      }
    })
  },
  onLoad: function (options){
    var type = options.type;
    this.setData({
      type: type
    });
    // 将发票的类型存全局变量
    app.globalData.type = type;
    app.globalData.typeaddress = type;
    wx.setStorageSync('type',type);
    var open_id = app.globalData.userInfo['openid'];
    wx.request({
        url: app.api.kzdsurl + '/FeijiUser/my_invoice',
        data: {
          openid: open_id
        },
        method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
        header: {// 设置请求的 header
          'Content-Type':  'application/x-www-form-urlencoded'
        },
        success:  (res) => {
          // success
          var result = res.data.data;
          console.log(result)
          var status = res.data.status;
          if(res.statusCode){
            this.setData({
              items: result
            })
          }
          // setTimeout(function(){
          //   wx.redirectTo({
          //     url: '../ticketchoose/index'
          //   });
          // },3000)
        },
        fail: function () {
          // fail
          wx.showToast({
            title: '网络异常！',
            icon: 'fail',
            duration: 2000
          });
        }
      })
  }
})